package lumis.portal.serviceinstance.serialization;

import java.util.EnumSet;

import lumis.portal.PortalException;
import lumis.portal.serialization.BaseSerializationContext;
import lumis.portal.serialization.SerializationMessageConfigNode;
import lumis.portal.serialization.DeserializationContext;
import lumis.portal.serialization.SerializationContext;
import lumis.portal.serialization.SerializationMessageConfigNode.RecursionStopPoints;
import lumis.portal.serialization.operation.IConfigDeleter;
import lumis.portal.serviceinstance.ServiceInstanceConfig;

/**
 * Manager Interface for Service Instance serialization
 *
 * @version $Revision: 8869 $ $Date: 2008-02-11 15:09:29 -0200 (Mon, 11 Feb 2008) $
 * @since 4.0.7
 */
public interface IServiceInstanceSerializationManager extends IConfigDeleter
{
	// DESERIALIZATION
	
	/**
	 * Deserialize a service instance.
	 * @param deserializationContext
	 * @param serviceInstanceSerializableConfig
	 * @throws PortalException
	 */
	public void deserialize(DeserializationContext deserializationContext, ServiceInstanceSerializableConfig serviceInstanceSerializableConfig) throws PortalException;

	/**
	 * Deserialize service instance content.
	 * @param deserializationContext
	 * @param serviceInstanceSerializableConfig
	 * @throws PortalException
	 */
	public void deserializeContent(DeserializationContext deserializationContext, ServiceInstanceSerializableConfig serviceInstanceSerializableConfig) throws PortalException;

	// SERIALIZATION
	
	/**
	 * Serialize a service instance.
	 * @param serializationContext
	 * @param serviceInstanceId
	 * @return
	 * @throws PortalException
	 */
	public ServiceInstanceSerializableConfig serialize(SerializationContext serializationContext, String serviceInstanceId) throws PortalException;

	// GENERAL
	
	/**
	 * Set up a serialization context, defining settings such as class aliases, field aliases, transient fields, omitted collections etc.
	 * @param serializationContext
	 */
	public void setupSerializationContext(BaseSerializationContext serializationContext);

	/**
	 * Get a {@link SerializationMessageConfigNode} object containing fully recursive information about a service instance.
	 * @param baseSerializationContext
	 * @param serviceInstanceConfig
	 * @return
	 * @throws PortalException
	 */
	public SerializationMessageConfigNode getSerializationMessageConfigNode(BaseSerializationContext baseSerializationContext, ServiceInstanceConfig serviceInstanceConfig) throws PortalException;

	/**
	 * Get a {@link SerializationMessageConfigNode} object containing partially recursive information about a service instance.
	 * @param baseSerializationContext
	 * @param serviceInstanceConfig
	 * @param recursionStopPoints
	 * @return
	 * @throws PortalException
	 */
	public SerializationMessageConfigNode getSerializationMessageConfigNode(BaseSerializationContext baseSerializationContext, ServiceInstanceConfig serviceInstanceConfig, EnumSet<RecursionStopPoints> recursionStopPoints) throws PortalException;
}
